import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;

public class Test {
    public static void main(String[] args) throws IOException {
        File file1=new File("D:/abc");
        File file2=new File("D:/abc/bbb");
        File file3=new File("D:/abc/bbb/test.txt");

        file1.mkdirs();
        file2.mkdirs();
        file3.createNewFile();

        FileWriter fw=new FileWriter("D:/abc/bbb/test.txt");
        BufferedWriter bw=new BufferedWriter(fw);
        bw.write("hello world");
        bw.close();
        fw.close();

        File file3B=new File("D:/abc/bbb/test2.txt");
        System.out.println(file3.renameTo(file3B));
        System.out.println("text2.txt文件长度为："+file3B.length());
        File file4=new File("d:/abc/bbb/hello.txt");
        file4.createNewFile();
        file4.renameTo(file1);
        //file3B.delete();

    }
}
